#region BLL VERSION  2.6
/* PhongBan
 *
 * Author: LANNT    
 * Copyright: (c) - LANNT 
 * Created:   07/09/2012 5:02:09 PM
 * Last modify: 2012-08-01 11:15 PM 
 * Note   :   Changes to this file may cause incorrect behavior and will be lost if
*            the code is regenerated.
*/
#endregion

#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using GQ.Utils;

using Chili.Opf3;
using Chili.Opf3.Relations;
using Chili.Opf3.DynamicProperties;
#endregion

namespace GQ.BLL.QuanLyKho
{
	#region PhongBan
	[Serializable]
	[Persistent("PHONGBAN", PoolSize = 10)]
	public partial class PhongBan 
	{
		#region Members
		private Guid _id=Guid.NewGuid();
		private string _ma=null;
		private string _ten=null;
		private string _ghichu=null;
		private Guid? _phongbanchaid=null;
		private Guid? _companyid=null;
		private string _diachi=null;
		private string _dienthoai=null;
		private string _fax=null;
		private int? _stt=null;
		#endregion
		
		#region Public Properties
		
		[Field("ID", Identifier=true, AllowDBNull=false)]
		public Guid ID
		{
			get{ return _id; }
			set{ _id = value; }
		}
		
		[Field("MA")]
		public string Ma
		{
			get{ return _ma; }
			set{ _ma = value; }
		}
		
		[Field("TEN")]
		public string Ten
		{
			get{ return _ten; }
			set{ _ten = value; }
		}
		
		[Field("GHICHU")]
		public string GhiChu
		{
			get{ return _ghichu; }
			set{ _ghichu = value; }
		}
		
		[Field("PHONGBANCHAID")]
		public Guid? PhongBanChaID
		{
			get{ return _phongbanchaid; }
			set{ _phongbanchaid = value; }
		}
		
		[Field("COMPANYID")]
		public Guid? CompanyID
		{
			get{ return _companyid; }
			set{ _companyid = value; }
		}
		
		[Field("DIACHI")]
		public string DiaChi
		{
			get{ return _diachi; }
			set{ _diachi = value; }
		}
		
		[Field("DIENTHOAI")]
		public string DienThoai
		{
			get{ return _dienthoai; }
			set{ _dienthoai = value; }
		}
		
		[Field("FAX")]
		public string Fax
		{
			get{ return _fax; }
			set{ _fax = value; }
		}
		
		[Field("STT")]
		public int? Stt
		{
			get{ return _stt; }
			set{ _stt = value; }
		}
		
		#endregion
		#region Methods Install
		public PhongBan LoadByID()
		{
		   return DbContext.ObjectContext.GetObject<PhongBan>("ID={0}",ID);
		}
		public static PhongBan LoadByID(Guid id)
		{
		   return DbContext.ObjectContext.GetObject<PhongBan>("ID={0}",id);
		}
		public void DeleteByID(Guid id)
		{
		   ID=id;
		   Chili.Opf3.ObjectInfo  objInfo= GQ.Utils.DbContext.ObjectContext.GetObjectInfo(this);
			  objInfo.ObjectState = Chili.Opf3.ObjectStates.Loaded;
			  objInfo.MarkForDeletion = true;
		   DbContext.ObjectContext.PersistChanges<PhongBan>(this);
		}
		public PhongBan LoadBy(string conditions, params object[] parameter)
		{
		   return DbContext.ObjectContext.GetObject<PhongBan>(conditions, parameter);
		}
		public void Save()
		{
		   DbContext.ObjectContext.PersistChanges<PhongBan>(this);
		}
		public void Delete()
		{
			 DbContext.ObjectContext.MarkForDeletion(this);
		   DbContext.ObjectContext.PersistChanges<PhongBan>(this);
		}
		#endregion Methods Install
		#region Methods Collection
		public static IList<PhongBan> LoadAll()
		{
		   return DbContext.ObjectContext.GetObjectSet<PhongBan>();
		}
		public static IList<PhongBan> LoadAll(string sortby)
		{
		   return DbContext.ObjectContext.GetObjectSet<PhongBan>("Sortby " + sortby);
		}
		public static IList<PhongBan> LoadAllBy(string conditions, params object[] parameter)
		{
		   return DbContext.ObjectContext.GetObjectSet<PhongBan>(conditions, parameter);
		}
		public static IList<PhongBan> LoadAllBy(Chili.Opf3.Query.SqlQuery query)
		{
		   return DbContext.ObjectContext.GetObjectSet<PhongBan>(query);
		}
		public static void SaveAll(IList<PhongBan> collection)
		{
		   foreach (PhongBan item in collection)
		   {
		       item.Save();
		   }
		}
		public static void DeleteAll(IList<PhongBan> collection)
		{
			foreach (PhongBan item in collection)
			{
		 		item.Delete();
			}
		}
		#endregion Methods Collection

	}
	#endregion
	
}
